<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
<h:head></h:head>
<h:form id="newUserForm">
    <rich:panel>
        <f:facet name="header">
            <h:outputText value="Создание нового пользователя"/>
        </f:facet>
        <h:panelGrid columns="3" >
            <h:outputText value="Имя:"/>
            <h:inputText id="name" value="#{wuserBoundary.wuser.name}" validatorMessage="Длинна поля от 3 до 20 символов">
                <f:validateLength minimum="3" maximum="20"/>
                <rich:validator />
            </h:inputText>
            <rich:message for="name"/>
            
            <h:outputText value="Заблокирован:"/>
            <h:selectBooleanCheckbox id="suspended" value="#{wuserBoundary.wuser.suspended}" 
                                     label="Заблокирован" title="Заблокирован"/>
            <rich:message for="suspended"/>
                        
            <h:outputText value="Права:"/>
            <rich:select id="role" value="#{wuserBoundary.wuser.wuserRole}" 
                         defaultLabel="выбрать из списка ..." validatorMessage="Поле не заполнено." >
                <f:selectItems value="#{wuserBoundary.wuserRolesValues()}" />
                <f:validateRequired/>
                <rich:validator/>
            </rich:select>
            <rich:message for="role"/>
            
            <h:outputText value="Эл. почта:"/>
            <h:inputText id="email" value="#{wuserBoundary.wuser.email}" 
                         validatorMessage="Неправильный адрес электронной почты">
                <f:validateRegex pattern="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" />
                <rich:validator />
            </h:inputText>
            <rich:message for="email"/>
          
            <h:outputText value="Пароль:"/>
            <h:inputSecret id="password" value="#{wuserBoundary.password}" validatorMessage="Обязательно для заполнения">
            	<f:validateRequired/>
                <rich:validator/>
            </h:inputSecret>
            <rich:message for="password"/>
        
            <h:outputText value="Подтверждение:"/>
            <h:inputSecret value="#{wuserBoundary.confirm}" />
            <h:outputText id="confirmMessage"/>
            
            <h:panelGroup>
                <h:outputText value="Организация "/><br/>
                <h:outputText value="по умолчанию:"/>
            </h:panelGroup>
            <h:outputText id="company" value="#{wuserBoundary.txtCompanyByDefault()}"/>
            <rich:message for="company"/>
            
            <h:panelGroup>
                <h:outputText value="Склад "/><br/>
                <h:outputText value="по умолчанию:"/>
            </h:panelGroup>
            <h:outputText id="warehouse" value="#{wuserBoundary.txtWarehouseByDefault()}"/>
            <rich:message for="warehouse"/>
            
            <h:panelGroup>
                <h:outputText value="Валюта "/><br/>
                <h:outputText value="по умолчанию:"/>
            </h:panelGroup>
            <h:outputText id="currency" value="#{wuserBoundary.txtCurrencyByDefault()}"/>
            <rich:message for="currency"/>
            
            <h:panelGroup>
                <h:outputText value="Дополнительные "/><br/>
                <h:outputText value="сведения:"/>
            </h:panelGroup>
            <h:inputTextarea id="description" value="#{wuserBoundary.wuser.description}" />
            <rich:message for="description"/>
             
        </h:panelGrid>
        
        <rich:toolbar>
            <h:commandButton value="OK" action="#{wuserBoundary.saveWuser()}"/>
            <h:commandButton value="Выйти" action="/pages/user/list.faces"  immediate="true"/>
        </rich:toolbar>
       
    </rich:panel>    
</h:form>
</html>
